package cn.edu.nju.software.zp13.core2.nodeDescriptorFactory.factoryFinder;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Predicate;

import cn.edu.nju.software.zp13.core2.nodeDescriptorFactory.ComplexNodeDescriptorFactory;
import cn.edu.nju.software.zp13.core2.nodeDescriptorFactory.NodeDescriptorFactory;
import cn.edu.nju.software.zp13.core2.xmlNodeEntity.XmlNodeEntity;

public class FieldNodeDescriptorFactoryMap {
	public static final Map<Predicate<Class<?>>,NodeDescriptorFactory> map=new HashMap<>();
	static{
		map.put(clazz->clazz.getSuperclass()==XmlNodeEntity.class, new ComplexNodeDescriptorFactory());
	}
	
	public NodeDescriptorFactory find(Class<?> fieldType){
		for(Predicate<Class<?>> p:map.keySet()){
			if(p.test(fieldType))
				return map.get(p);
			
		}
		return null;
	}
}
